home *** CD-ROM | disk | FTP | other *** search
- real timeArray[];
- integer oldTicks, oldWait, isConnected, duringSim;
- integer messageIn, DiscreteModel, dialogIsOpen;
-
- ** This block displays the value at its input connector during
- ** the simulation run.
- **
- ** Copyright © 1989-1994 by Imagine That,Inc.
- ** All Rights Reserved.
- ** Extend Generic Library, ReadOut block; J. Steven Lamperti 7/90
- ** modified
- ** 1/7/92 JSL Extensively mnodified for V2.0
- ** 11/23/92 JSL fix for generic blocks in discrete models
- ** 6/24/93 JSL don't calc when animation off and open false
- ** 6/28/93 JSL added dialogIsOpen
- ** 1/17/93 JSL added duringSim
- ** 2/15/94 DJK modified trace and report
- ** 3/10/94 DJK added block label to report & trace
- ** 3/23/94 DJK removed code that prevented value from updating if block was not open or animation was not on.
- ** 4/6/94 JSL uncommented !open !animationOn !dialogIsOpen Return,
- ** with extra if (isConnected) before it.
- ** 4/6/94 JSL added initialization of oldTicks in several places
- **
-
- procedure calc()
- {
- if (isConnected)
- Value = valueIn;
-
- if (!open and !animationOn and !dialogIsOpen)
- return;
-
- if (isConnected)
- {
- Value = valueIn;
-
- if (animationOn)
- {
- animationText(1, value);
- animationShow(1);
- }
- else if (open && !dialogIsOpen)
- OpenDialogBox();
-
- oldWait = tickCount()-oldTicks;
- if (oldWait < ticks)
- WaitNTicks(ticks-oldWait);
-
- oldTicks = tickCount();
- }
-
- ** sysGlobal2 is the file reference number for the DEBUG TRACE
- if( sysGlobal2 != 0.0 ) ** 0 is error, check for open file for TRACE
- {
- // template for report: |BLOCK NAME *****************|block number |BLOCK NUMBER*******
- fileWrite(sysGlobal2,"ReadOut block number "+(MyBlockNumber())+". Current Time:"+currentTime+".","",True);
- if(getBlockLabel(myBlockNumber()) != "")
- fileWrite(sysGlobal2,"Block Label: "+getBlockLabel(myBlockNumber()),"",True);
- fileWrite(sysGlobal2," Input = "+valueIn,"",True);
- fileWrite(sysGlobal2," ","",True);
- }
- }
-
-
- // on valueIn is a message handler that is only used by this block when the
- // block is used in Discrete Event models.
-
- on valueIn
- {
- messageIn = TRUE;
- calc();
- }
-
-
- on dialogOpen
- {
- oldTicks = 0;
- calc();
- dialogIsOpen = TRUE;
- }
-
-
- on openModel
- {
- oldTicks = 0;
- }
-
-
- on dialogClose
- {
- dialogIsOpen = FALSE;
- if (duringSim)
- open = FALSE;
- }
-
-
- ** This message occurs for each step in the simulation.
- on simulate
- {
- if (messageIn) // Discrete models. We've gotten a message, so no sim messages.
- {
- GetSimulateMsgs(FALSE);
- return;
- }
-
- if (DiscreteModel)
- sendMsgToOutputs(valueIn);
- calc();
- }
-
-
- ** If the dialog data is inconsistent for simulation, abort.
- on checkdata
- {
- messageIn = FALSE;
- isConnected = valueIn; ** true if connected
-
- if (animationOn)
- {
- AnimationText(1, "0");
- AnimationShow(1);
- }
- else
- AnimationHide(1, FALSE);
-
- if (NoValue(ticks) || ticks < 0)
- ticks = 0;
- }
-
-
- on createBlock
- {
- oldTicks = 0;
- open = TRUE;
- ticks = 2;
- messageIn = FALSE;
- dialogIsOpen = FALSE;
- }
-
-
- ** Initialize any simulation variables.
- on initsim
- {
- Value = BLANK;
- oldTicks = 0;
-
- DiscreteModel = getPassedArray(sysGlobal0, timeArray);
- duringSim = TRUE;
- }
-
-
- on abortSim
- {
- duringSim = FALSE;
- }
-
-
- on endSim
- {
- duringSim = FALSE;
- if (isConnected)
- Value = valueIn;
-
- ** sysGlobal1 is the file reference number for the TEXT REPORT
- if( sysGlobal1 != 0.0 ) ** 0 is error, check for open file for REPORT
- {
- // template for report: |BLOCK NAME *****************|block number |BLOCK NUMBER*******
- fileWrite(sysGlobal1,"ReadOut block number "+MyBlockNumber(),"",True);
- if(getBlockLabel(myBlockNumber()) != "")
- fileWrite(sysGlobal1,"Block Label: "+getBlockLabel(myBlockNumber()),"",True);
- fileWrite(sysGlobal1," ","",True);
- }
- }